<?php


namespace app\common\model;


use think\Model;

class CommentReplyModel extends Model
{
    protected $name = 'comment_reply';




    /**
     * 修改点赞量
     * @param int $id
     * @param string $type setInc,setDec
     * @return array
     */
    public static function editLikeNum(int $id, $type): array
    {
        try {
            self::where('id',$id)->$type('like',1);

            return [
                'code' => 200,
                'msg' => '请求成功',
                'data' => []
            ];
        }catch (\Exception $e) {
            return [
                'code' => $e->getCode(),
                'msg' => $e->getMessage(),
                'data' => []
            ];
        }
    }

    public function from()
    {
        return $this->belongsTo('app\common\model\User', 'from_uid', 'id');
    }

    public function to()
    {
        return $this->belongsTo('app\common\model\User', 'to_uid', 'id');
    }
}